package day3_方法;

public class aaaaa {

    public static void main ( String[] strs ) {
        // 1.方法重载与参数的数量和顺序有关，与参数的返回值等无关；两个方法返回值不同其余相同不构成方法重载

        // everyNum(5);
        // remainder( 12334 );
        // System.out.println(getMax(12,45));
        // System.out.println(getMax(12.2,45.7));
        // System.out.println(getMax(12.1,45.3, 22.5));
    }

    // 输出和
    public static void everyNum ( int num ) {
        int sum = 0;
        for (int i = 1; i < num+1; i++) {
            sum += i;
        }
        System.out.println(sum);
    }

    // 输出位数
    public static void remainder ( int num ) {
        int sum = 0;
        while ( num > 0 ){
            num /= 10;
            sum++;
        }
        System.out.println(sum);
    }

    // 获取最大值的三个重载的方法
    public static int getMax ( int a, int b) {
        if (a > b) {
            return a;
        }else { return b; }
    }
    public static double getMax ( double a, double b) {
        if (a > b) {
            return a;
        }else { return b; }
    }
    public static double getMax ( double a, double b, double c ) {
        if ( a > b & a > c) {
            return a;
        } else if ( b > a & b > c ) {
            return b;
        } else { return c; }
    }
}
